
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>下标 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../../../../../../0/style.css">

    
            
                
                <link rel="stylesheet" href="../../../../../../0/website.css">
                
            
                
                <link rel="stylesheet" href="../../../../../../0/search.css">
                
            
                
                <link rel="stylesheet" href="../../../../../../0/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="13_Inheritance.html" />
    
    
    <link rel="prev" href="11_Methods.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" >
            
                <span>
            
                    
                    欢迎使用 Swift
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../chapter1/01_about_swift.html">
            
                <a href="../chapter1/01_about_swift.html">
            
                    
                    关于 Swift
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../chapter1/02_version_compatibility.html">
            
                <a href="../chapter1/02_version_compatibility.html">
            
                    
                    版本兼容性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../chapter1/03_a_swift_tour.html">
            
                <a href="../chapter1/03_a_swift_tour.html">
            
                    
                    Swift 初见
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../chapter1/04_revision_history.html">
            
                <a href="../chapter1/04_revision_history.html">
            
                    
                    Swift 版本历史记录
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" >
            
                <span>
            
                    
                    Swift 教程
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="01_The_Basics.html">
            
                <a href="01_The_Basics.html">
            
                    
                    基础部分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="02_Basic_Operators.html">
            
                <a href="02_Basic_Operators.html">
            
                    
                    基本运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="03_Strings_and_Characters.html">
            
                <a href="03_Strings_and_Characters.html">
            
                    
                    字符串和字符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="04_Collection_Types.html">
            
                <a href="04_Collection_Types.html">
            
                    
                    集合类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="05_Control_Flow.html">
            
                <a href="05_Control_Flow.html">
            
                    
                    控制流
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.6" data-path="06_Functions.html">
            
                <a href="06_Functions.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.7" data-path="07_Closures.html">
            
                <a href="07_Closures.html">
            
                    
                    闭包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.8" data-path="08_Enumerations.html">
            
                <a href="08_Enumerations.html">
            
                    
                    枚举
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.9" data-path="09_Structures_And_Classes.html">
            
                <a href="09_Structures_And_Classes.html">
            
                    
                    类和结构体
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.10" data-path="10_Properties.html">
            
                <a href="10_Properties.html">
            
                    
                    属性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.11" data-path="11_Methods.html">
            
                <a href="11_Methods.html">
            
                    
                    方法
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.12" data-path="12_Subscripts.html">
            
                <a href="12_Subscripts.html">
            
                    
                    下标
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.13" data-path="13_Inheritance.html">
            
                <a href="13_Inheritance.html">
            
                    
                    继承
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.14" data-path="14_Initialization.html">
            
                <a href="14_Initialization.html">
            
                    
                    构造过程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.15" data-path="15_Deinitialization.html">
            
                <a href="15_Deinitialization.html">
            
                    
                    析构过程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.16" data-path="16_Optional_Chaining.html">
            
                <a href="16_Optional_Chaining.html">
            
                    
                    可选链
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.17" data-path="17_Error_Handling.html">
            
                <a href="17_Error_Handling.html">
            
                    
                    错误处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.18" data-path="18_Type_Casting.html">
            
                <a href="18_Type_Casting.html">
            
                    
                    类型转换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.19" data-path="19_Nested_Types.html">
            
                <a href="19_Nested_Types.html">
            
                    
                    嵌套类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.20" data-path="20_Extensions.html">
            
                <a href="20_Extensions.html">
            
                    
                    扩展
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.21" data-path="21_Protocols.html">
            
                <a href="21_Protocols.html">
            
                    
                    协议
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.22" data-path="22_Generics.html">
            
                <a href="22_Generics.html">
            
                    
                    泛型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.23" data-path="23_Automatic_Reference_Counting.html">
            
                <a href="23_Automatic_Reference_Counting.html">
            
                    
                    自动引用计数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.24" data-path="24_Memory_Safety.html">
            
                <a href="24_Memory_Safety.html">
            
                    
                    内存安全
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.25" data-path="25_Access_Control.html">
            
                <a href="25_Access_Control.html">
            
                    
                    访问控制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.26" data-path="26_Advanced_Operators.html">
            
                <a href="26_Advanced_Operators.html">
            
                    
                    高级运算符
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" >
            
                <span>
            
                    
                    语言参考
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../chapter3/01_About_the_Language_Reference.html">
            
                <a href="../chapter3/01_About_the_Language_Reference.html">
            
                    
                    关于语言参考
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../chapter3/02_Lexical_Structure.html">
            
                <a href="../chapter3/02_Lexical_Structure.html">
            
                    
                    词法结构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../chapter3/03_Types.html">
            
                <a href="../chapter3/03_Types.html">
            
                    
                    类型
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="../chapter3/04_Expressions.html">
            
                <a href="../chapter3/04_Expressions.html">
            
                    
                    表达式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.5" data-path="../chapter3/05_Statements.html">
            
                <a href="../chapter3/05_Statements.html">
            
                    
                    语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="../chapter3/06_Declarations.html">
            
                <a href="../chapter3/06_Declarations.html">
            
                    
                    声明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.7" data-path="../chapter3/07_Attributes.html">
            
                <a href="../chapter3/07_Attributes.html">
            
                    
                    特性
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.8" data-path="../chapter3/08_Patterns.html">
            
                <a href="../chapter3/08_Patterns.html">
            
                    
                    模式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.9" data-path="../chapter3/09_Generic_Parameters_and_Arguments.html">
            
                <a href="../chapter3/09_Generic_Parameters_and_Arguments.html">
            
                    
                    泛型参数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.10" data-path="../chapter3/10_Summary_of_the_Grammar.html">
            
                <a href="../chapter3/10_Summary_of_the_Grammar.html">
            
                    
                    语法总结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" >
            
                <span>
            
                    
                    翻译贡献者
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../contributors.html">
            
                <a href="../contributors.html">
            
                    
                    翻译贡献者
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >下标</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x4E0B;&#x6807;">&#x4E0B;&#x6807;</h1>
<p><em>&#x4E0B;&#x6807;</em>&#x53EF;&#x4EE5;&#x5B9A;&#x4E49;&#x5728;&#x7C7B;&#x3001;&#x7ED3;&#x6784;&#x4F53;&#x548C;&#x679A;&#x4E3E;&#x4E2D;&#xFF0C;&#x662F;&#x8BBF;&#x95EE;&#x96C6;&#x5408;&#x3001;&#x5217;&#x8868;&#x6216;&#x5E8F;&#x5217;&#x4E2D;&#x5143;&#x7D20;&#x7684;&#x5FEB;&#x6377;&#x65B9;&#x5F0F;&#x3002;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4E0B;&#x6807;&#x7684;&#x7D22;&#x5F15;&#xFF0C;&#x8BBE;&#x7F6E;&#x548C;&#x83B7;&#x53D6;&#x503C;&#xFF0C;&#x800C;&#x4E0D;&#x9700;&#x8981;&#x518D;&#x8C03;&#x7528;&#x5BF9;&#x5E94;&#x7684;&#x5B58;&#x53D6;&#x65B9;&#x6CD5;&#x3002;&#x4E3E;&#x4F8B;&#x6765;&#x8BF4;&#xFF0C;&#x7528;&#x4E0B;&#x6807;&#x8BBF;&#x95EE;&#x4E00;&#x4E2A; <code>Array</code> &#x5B9E;&#x4F8B;&#x4E2D;&#x7684;&#x5143;&#x7D20;&#x53EF;&#x4EE5;&#x5199;&#x4F5C; <code>someArray[index]</code>&#xFF0C;&#x8BBF;&#x95EE; <code>Dictionary</code> &#x5B9E;&#x4F8B;&#x4E2D;&#x7684;&#x5143;&#x7D20;&#x53EF;&#x4EE5;&#x5199;&#x4F5C; <code>someDictionary[key]</code>&#x3002;</p>
<p>&#x4E00;&#x4E2A;&#x7C7B;&#x578B;&#x53EF;&#x4EE5;&#x5B9A;&#x4E49;&#x591A;&#x4E2A;&#x4E0B;&#x6807;&#xFF0C;&#x901A;&#x8FC7;&#x4E0D;&#x540C;&#x7D22;&#x5F15;&#x7C7B;&#x578B;&#x8FDB;&#x884C;&#x91CD;&#x8F7D;&#x3002;&#x4E0B;&#x6807;&#x4E0D;&#x9650;&#x4E8E;&#x4E00;&#x7EF4;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x5B9A;&#x4E49;&#x5177;&#x6709;&#x591A;&#x4E2A;&#x5165;&#x53C2;&#x7684;&#x4E0B;&#x6807;&#x6EE1;&#x8DB3;&#x81EA;&#x5B9A;&#x4E49;&#x7C7B;&#x578B;&#x7684;&#x9700;&#x6C42;&#x3002;</p>
<h2 id="subscript-syntax">&#x4E0B;&#x6807;&#x8BED;&#x6CD5; </h2>
<p>&#x4E0B;&#x6807;&#x5141;&#x8BB8;&#x4F60;&#x901A;&#x8FC7;&#x5728;&#x5B9E;&#x4F8B;&#x540D;&#x79F0;&#x540E;&#x9762;&#x7684;&#x65B9;&#x62EC;&#x53F7;&#x4E2D;&#x4F20;&#x5165;&#x4E00;&#x4E2A;&#x6216;&#x8005;&#x591A;&#x4E2A;&#x7D22;&#x5F15;&#x503C;&#x6765;&#x5BF9;&#x5B9E;&#x4F8B;&#x8FDB;&#x884C;&#x5B58;&#x53D6;&#x3002;&#x8BED;&#x6CD5;&#x7C7B;&#x4F3C;&#x4E8E;&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;&#x8BED;&#x6CD5;&#x548C;&#x8BA1;&#x7B97;&#x578B;&#x5C5E;&#x6027;&#x8BED;&#x6CD5;&#x7684;&#x6DF7;&#x5408;&#x3002;&#x4E0E;&#x5B9A;&#x4E49;&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;&#x7C7B;&#x4F3C;&#xFF0C;&#x5B9A;&#x4E49;&#x4E0B;&#x6807;&#x4F7F;&#x7528; <code>subscript</code> &#x5173;&#x952E;&#x5B57;&#xFF0C;&#x6307;&#x5B9A;&#x4E00;&#x4E2A;&#x6216;&#x591A;&#x4E2A;&#x8F93;&#x5165;&#x53C2;&#x6570;&#x548C;&#x8FD4;&#x56DE;&#x7C7B;&#x578B;&#xFF1B;&#x4E0E;&#x5B9E;&#x4F8B;&#x65B9;&#x6CD5;&#x4E0D;&#x540C;&#x7684;&#x662F;&#xFF0C;&#x4E0B;&#x6807;&#x53EF;&#x4EE5;&#x8BBE;&#x5B9A;&#x4E3A;&#x8BFB;&#x5199;&#x6216;&#x53EA;&#x8BFB;&#x3002;&#x8FD9;&#x79CD;&#x884C;&#x4E3A;&#x7531; getter &#x548C; setter &#x5B9E;&#x73B0;&#xFF0C;&#x6709;&#x70B9;&#x7C7B;&#x4F3C;&#x8BA1;&#x7B97;&#x578B;&#x5C5E;&#x6027;&#xFF1A;</p>
<pre><code class="lang-swift"><span class="hljs-keyword">subscript</span>(index: <span class="hljs-type">Int</span>) -&gt; <span class="hljs-type">Int</span> {
    <span class="hljs-keyword">get</span> {
      <span class="hljs-comment">// &#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x9002;&#x5F53;&#x7684; Int &#x7C7B;&#x578B;&#x7684;&#x503C;</span>
    }
    <span class="hljs-keyword">set</span>(newValue) {
      <span class="hljs-comment">// &#x6267;&#x884C;&#x9002;&#x5F53;&#x7684;&#x8D4B;&#x503C;&#x64CD;&#x4F5C;</span>
    }
}
</code></pre>
<p><code>newValue</code> &#x7684;&#x7C7B;&#x578B;&#x548C;&#x4E0B;&#x6807;&#x7684;&#x8FD4;&#x56DE;&#x7C7B;&#x578B;&#x76F8;&#x540C;&#x3002;&#x5982;&#x540C;&#x8BA1;&#x7B97;&#x578B;&#x5C5E;&#x6027;&#xFF0C;&#x53EF;&#x4EE5;&#x4E0D;&#x6307;&#x5B9A; setter &#x7684;&#x53C2;&#x6570;&#xFF08;<code>newValue</code>&#xFF09;&#x3002;&#x5982;&#x679C;&#x4E0D;&#x6307;&#x5B9A;&#x53C2;&#x6570;&#xFF0C;setter &#x4F1A;&#x63D0;&#x4F9B;&#x4E00;&#x4E2A;&#x540D;&#x4E3A; <code>newValue</code> &#x7684;&#x9ED8;&#x8BA4;&#x53C2;&#x6570;&#x3002;</p>
<p>&#x5982;&#x540C;&#x53EA;&#x8BFB;&#x8BA1;&#x7B97;&#x578B;&#x5C5E;&#x6027;&#xFF0C;&#x53EF;&#x4EE5;&#x7701;&#x7565;&#x53EA;&#x8BFB;&#x4E0B;&#x6807;&#x7684; <code>get</code> &#x5173;&#x952E;&#x5B57;&#xFF1A;</p>
<pre><code class="lang-swift"><span class="hljs-keyword">subscript</span>(index: <span class="hljs-type">Int</span>) -&gt; <span class="hljs-type">Int</span> {
    <span class="hljs-comment">// &#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x9002;&#x5F53;&#x7684; Int &#x7C7B;&#x578B;&#x7684;&#x503C;</span>
}
</code></pre>
<p>&#x4E0B;&#x9762;&#x4EE3;&#x7801;&#x6F14;&#x793A;&#x4E86;&#x53EA;&#x8BFB;&#x4E0B;&#x6807;&#x7684;&#x5B9E;&#x73B0;&#xFF0C;&#x8FD9;&#x91CC;&#x5B9A;&#x4E49;&#x4E86;&#x4E00;&#x4E2A; <code>TimesTable</code> &#x7ED3;&#x6784;&#x4F53;&#xFF0C;&#x7528;&#x6765;&#x8868;&#x793A;&#x4F20;&#x5165;&#x6574;&#x6570;&#x7684;&#x4E58;&#x6CD5;&#x8868;&#xFF1A;</p>
<pre><code class="lang-swift"><span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">TimesTable</span> </span>{
    <span class="hljs-keyword">let</span> multiplier: <span class="hljs-type">Int</span>
    <span class="hljs-keyword">subscript</span>(index: <span class="hljs-type">Int</span>) -&gt; <span class="hljs-type">Int</span> {
        <span class="hljs-keyword">return</span> multiplier * index
    }
}
<span class="hljs-keyword">let</span> threeTimesTable = <span class="hljs-type">TimesTable</span>(multiplier: <span class="hljs-number">3</span>)
<span class="hljs-built_in">print</span>(<span class="hljs-string">&quot;six times three is <span class="hljs-subst">\(threeTimesTable[<span class="hljs-number">6</span>])</span>&quot;</span>)
<span class="hljs-comment">// &#x6253;&#x5370;&#x201C;six times three is 18&#x201D;</span>
</code></pre>
<p>&#x5728;&#x4E0A;&#x4F8B;&#x4E2D;&#xFF0C;&#x521B;&#x5EFA;&#x4E86;&#x4E00;&#x4E2A; <code>TimesTable</code> &#x5B9E;&#x4F8B;&#xFF0C;&#x7528;&#x6765;&#x8868;&#x793A;&#x6574;&#x6570; <code>3</code> &#x7684;&#x4E58;&#x6CD5;&#x8868;&#x3002;&#x6570;&#x503C; <code>3</code> &#x88AB;&#x4F20;&#x9012;&#x7ED9;&#x7ED3;&#x6784;&#x4F53;&#x7684;&#x6784;&#x9020;&#x51FD;&#x6570;&#xFF0C;&#x4F5C;&#x4E3A;&#x5B9E;&#x4F8B;&#x6210;&#x5458; <code>multiplier</code> &#x7684;&#x503C;&#x3002;</p>
<p>&#x4F60;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4E0B;&#x6807;&#x8BBF;&#x95EE; <code>threeTimesTable</code> &#x5B9E;&#x4F8B;&#xFF0C;&#x4F8B;&#x5982;&#x4E0A;&#x9762;&#x6F14;&#x793A;&#x7684; <code>threeTimesTable[6]</code>&#x3002;&#x8FD9;&#x6761;&#x8BED;&#x53E5;&#x67E5;&#x8BE2;&#x4E86; <code>3</code> &#x7684;&#x4E58;&#x6CD5;&#x8868;&#x4E2D;&#x7684;&#x7B2C;&#x516D;&#x4E2A;&#x5143;&#x7D20;&#xFF0C;&#x8FD4;&#x56DE; <code>3</code> &#x7684; <code>6</code> &#x500D;&#x5373; <code>18</code>&#x3002;</p>
<blockquote>
<p>&#x6CE8;&#x610F;</p>
<p><code>TimesTable</code> &#x4F8B;&#x5B50;&#x57FA;&#x4E8E;&#x4E00;&#x4E2A;&#x56FA;&#x5B9A;&#x7684;&#x6570;&#x5B66;&#x516C;&#x5F0F;&#xFF0C;&#x5BF9; <code>threeTimesTable[someIndex]</code> &#x8FDB;&#x884C;&#x8D4B;&#x503C;&#x64CD;&#x4F5C;&#x5E76;&#x4E0D;&#x5408;&#x9002;&#xFF0C;&#x56E0;&#x6B64;&#x4E0B;&#x6807;&#x5B9A;&#x4E49;&#x4E3A;&#x53EA;&#x8BFB;&#x7684;&#x3002;</p>
</blockquote>
<h2 id="subscript-usage">&#x4E0B;&#x6807;&#x7528;&#x6CD5; </h2>
<p>&#x4E0B;&#x6807;&#x7684;&#x786E;&#x5207;&#x542B;&#x4E49;&#x53D6;&#x51B3;&#x4E8E;&#x4F7F;&#x7528;&#x573A;&#x666F;&#x3002;&#x4E0B;&#x6807;&#x901A;&#x5E38;&#x4F5C;&#x4E3A;&#x8BBF;&#x95EE;&#x96C6;&#x5408;&#xFF0C;&#x5217;&#x8868;&#x6216;&#x5E8F;&#x5217;&#x4E2D;&#x5143;&#x7D20;&#x7684;&#x5FEB;&#x6377;&#x65B9;&#x5F0F;&#x3002;&#x4F60;&#x53EF;&#x4EE5;&#x9488;&#x5BF9;&#x81EA;&#x5DF1;&#x7279;&#x5B9A;&#x7684;&#x7C7B;&#x6216;&#x7ED3;&#x6784;&#x4F53;&#x7684;&#x529F;&#x80FD;&#x6765;&#x81EA;&#x7531;&#x5730;&#x4EE5;&#x6700;&#x6070;&#x5F53;&#x7684;&#x65B9;&#x5F0F;&#x5B9E;&#x73B0;&#x4E0B;&#x6807;&#x3002;</p>
<p>&#x4F8B;&#x5982;&#xFF0C;Swift &#x7684; <code>Dictionary</code> &#x7C7B;&#x578B;&#x5B9E;&#x73B0;&#x4E0B;&#x6807;&#x7528;&#x4E8E;&#x5BF9;&#x5176;&#x5B9E;&#x4F8B;&#x4E2D;&#x50A8;&#x5B58;&#x7684;&#x503C;&#x8FDB;&#x884C;&#x5B58;&#x53D6;&#x64CD;&#x4F5C;&#x3002;&#x4E3A;&#x5B57;&#x5178;&#x8BBE;&#x503C;&#x65F6;&#xFF0C;&#x5728;&#x4E0B;&#x6807;&#x4E2D;&#x4F7F;&#x7528;&#x548C;&#x5B57;&#x5178;&#x7684;&#x952E;&#x7C7B;&#x578B;&#x76F8;&#x540C;&#x7684;&#x952E;&#xFF0C;&#x5E76;&#x628A;&#x4E00;&#x4E2A;&#x548C;&#x5B57;&#x5178;&#x7684;&#x503C;&#x7C7B;&#x578B;&#x76F8;&#x540C;&#x7684;&#x503C;&#x8D4B;&#x7ED9;&#x8FD9;&#x4E2A;&#x4E0B;&#x6807;&#xFF1A;</p>
<pre><code class="lang-swift"><span class="hljs-keyword">var</span> numberOfLegs = [<span class="hljs-string">&quot;spider&quot;</span>: <span class="hljs-number">8</span>, <span class="hljs-string">&quot;ant&quot;</span>: <span class="hljs-number">6</span>, <span class="hljs-string">&quot;cat&quot;</span>: <span class="hljs-number">4</span>]
numberOfLegs[<span class="hljs-string">&quot;bird&quot;</span>] = <span class="hljs-number">2</span>
</code></pre>
<p>&#x4E0A;&#x4F8B;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x540D;&#x4E3A; <code>numberOfLegs</code> &#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x5E76;&#x7528;&#x4E00;&#x4E2A;&#x5305;&#x542B;&#x4E09;&#x5BF9;&#x952E;&#x503C;&#x7684;&#x5B57;&#x5178;&#x5B57;&#x9762;&#x91CF;&#x521D;&#x59CB;&#x5316;&#x5B83;&#x3002;<code>numberOfLegs</code> &#x5B57;&#x5178;&#x7684;&#x7C7B;&#x578B;&#x88AB;&#x63A8;&#x65AD;&#x4E3A; <code>[String: Int]</code>&#x3002;&#x5B57;&#x5178;&#x521B;&#x5EFA;&#x5B8C;&#x6210;&#x540E;&#xFF0C;&#x8BE5;&#x4F8B;&#x5B50;&#x901A;&#x8FC7;&#x4E0B;&#x6807;&#x5C06; <code>String</code> &#x7C7B;&#x578B;&#x7684;&#x952E; <code>bird</code> &#x548C; <code>Int</code> &#x7C7B;&#x578B;&#x7684;&#x503C; <code>2</code> &#x6DFB;&#x52A0;&#x5230;&#x5B57;&#x5178;&#x4E2D;&#x3002;</p>
<p>&#x66F4;&#x591A;&#x5173;&#x4E8E; <code>Dictionary</code> &#x4E0B;&#x6807;&#x7684;&#x4FE1;&#x606F;&#x8BF7;&#x53C2;&#x8003; <a href="04_Collection_Types.html#accessing_and_modifying_a_dictionary">&#x8BFB;&#x53D6;&#x548C;&#x4FEE;&#x6539;&#x5B57;&#x5178;</a>&#x3002;</p>
<blockquote>
<p>&#x6CE8;&#x610F;</p>
<p>Swift &#x7684; <code>Dictionary</code> &#x7C7B;&#x578B;&#x7684;&#x4E0B;&#x6807;&#x63A5;&#x53D7;&#x5E76;&#x8FD4;&#x56DE;&#x53EF;&#x9009;&#x7C7B;&#x578B;&#x7684;&#x503C;&#x3002;&#x4E0A;&#x4F8B;&#x4E2D;&#x7684; <code>numberOfLegs</code> &#x5B57;&#x5178;&#x901A;&#x8FC7;&#x4E0B;&#x6807;&#x8FD4;&#x56DE;&#x7684;&#x662F;&#x4E00;&#x4E2A; <code>Int?</code> &#x6216;&#x8005;&#x8BF4;&#x201C;&#x53EF;&#x9009;&#x7684; int&#x201D;&#x3002;<code>Dictionary</code> &#x7C7B;&#x578B;&#x4E4B;&#x6240;&#x4EE5;&#x5982;&#x6B64;&#x5B9E;&#x73B0;&#x4E0B;&#x6807;&#xFF0C;&#x662F;&#x56E0;&#x4E3A;&#x4E0D;&#x662F;&#x6BCF;&#x4E2A;&#x952E;&#x90FD;&#x6709;&#x4E2A;&#x5BF9;&#x5E94;&#x7684;&#x503C;&#xFF0C;&#x540C;&#x65F6;&#x8FD9;&#x4E5F;&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x79CD;&#x901A;&#x8FC7;&#x952E;&#x5220;&#x9664;&#x5BF9;&#x5E94;&#x503C;&#x7684;&#x65B9;&#x5F0F;&#xFF0C;&#x53EA;&#x9700;&#x5C06;&#x952E;&#x5BF9;&#x5E94;&#x7684;&#x503C;&#x8D4B;&#x503C;&#x4E3A; <code>nil</code> &#x5373;&#x53EF;&#x3002;</p>
</blockquote>
<h2 id="subscript-options">&#x4E0B;&#x6807;&#x9009;&#x9879; </h2>
<p>&#x4E0B;&#x6807;&#x53EF;&#x4EE5;&#x63A5;&#x53D7;&#x4EFB;&#x610F;&#x6570;&#x91CF;&#x7684;&#x5165;&#x53C2;&#xFF0C;&#x5E76;&#x4E14;&#x8FD9;&#x4E9B;&#x5165;&#x53C2;&#x53EF;&#x4EE5;&#x662F;&#x4EFB;&#x610F;&#x7C7B;&#x578B;&#x3002;&#x4E0B;&#x6807;&#x7684;&#x8FD4;&#x56DE;&#x503C;&#x4E5F;&#x53EF;&#x4EE5;&#x662F;&#x4EFB;&#x610F;&#x7C7B;&#x578B;&#x3002;&#x4E0B;&#x6807;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x53EF;&#x53D8;&#x53C2;&#x6570;&#xFF0C;&#x5E76;&#x4E14;&#x53EF;&#x4EE5;&#x63D0;&#x4F9B;&#x9ED8;&#x8BA4;&#x53C2;&#x6570;&#x6570;&#x503C;&#xFF0C;&#x4F46;&#x662F;&#x4E0D;&#x80FD;&#x4F7F;&#x7528;&#x8F93;&#x5165;&#x8F93;&#x51FA;&#x53C2;&#x6570;&#x3002;</p>
<p>&#x4E00;&#x4E2A;&#x7C7B;&#x6216;&#x7ED3;&#x6784;&#x4F53;&#x53EF;&#x4EE5;&#x6839;&#x636E;&#x81EA;&#x8EAB;&#x9700;&#x8981;&#x63D0;&#x4F9B;&#x591A;&#x4E2A;&#x4E0B;&#x6807;&#x5B9E;&#x73B0;&#xFF0C;&#x4F7F;&#x7528;&#x4E0B;&#x6807;&#x65F6;&#x5C06;&#x901A;&#x8FC7;&#x5165;&#x53C2;&#x7684;&#x6570;&#x91CF;&#x548C;&#x7C7B;&#x578B;&#x8FDB;&#x884C;&#x533A;&#x5206;&#xFF0C;&#x81EA;&#x52A8;&#x5339;&#x914D;&#x5408;&#x9002;&#x7684;&#x4E0B;&#x6807;&#xFF0C;&#x8FD9;&#x5C31;&#x662F;<em>&#x4E0B;&#x6807;&#x7684;&#x91CD;&#x8F7D;</em>&#x3002;</p>
<p>&#x867D;&#x7136;&#x63A5;&#x53D7;&#x5355;&#x4E00;&#x5165;&#x53C2;&#x7684;&#x4E0B;&#x6807;&#x662F;&#x6700;&#x5E38;&#x89C1;&#x7684;&#xFF0C;&#x4F46;&#x4E5F;&#x53EF;&#x4EE5;&#x6839;&#x636E;&#x60C5;&#x51B5;&#x5B9A;&#x4E49;&#x63A5;&#x53D7;&#x591A;&#x4E2A;&#x5165;&#x53C2;&#x7684;&#x4E0B;&#x6807;&#x3002;&#x4F8B;&#x5982;&#x4E0B;&#x4F8B;&#x5B9A;&#x4E49;&#x4E86;&#x4E00;&#x4E2A; <code>Matrix</code> &#x7ED3;&#x6784;&#x4F53;&#xFF0C;&#x7528;&#x4E8E;&#x8868;&#x793A;&#x4E00;&#x4E2A; <code>Double</code> &#x7C7B;&#x578B;&#x7684;&#x4E8C;&#x7EF4;&#x77E9;&#x9635;&#x3002;<code>Matrix</code> &#x7ED3;&#x6784;&#x4F53;&#x7684;&#x4E0B;&#x6807;&#x63A5;&#x53D7;&#x4E24;&#x4E2A;&#x6574;&#x578B;&#x53C2;&#x6570;&#xFF1A;</p>
<pre><code class="lang-swift"><span class="hljs-class"><span class="hljs-keyword">struct</span> <span class="hljs-title">Matrix</span> </span>{
    <span class="hljs-keyword">let</span> rows: <span class="hljs-type">Int</span>, columns: <span class="hljs-type">Int</span>
    <span class="hljs-keyword">var</span> grid: [<span class="hljs-type">Double</span>]
    <span class="hljs-keyword">init</span>(rows: <span class="hljs-type">Int</span>, columns: <span class="hljs-type">Int</span>) {
        <span class="hljs-keyword">self</span>.rows = rows
        <span class="hljs-keyword">self</span>.columns = columns
        grid = <span class="hljs-type">Array</span>(repeating: <span class="hljs-number">0.0</span>, <span class="hljs-built_in">count</span>: rows * columns)
    }
    <span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">indexIsValid</span><span class="hljs-params">(row: Int, column: Int)</span></span> -&gt; <span class="hljs-type">Bool</span> {
        <span class="hljs-keyword">return</span> row &gt;= <span class="hljs-number">0</span> &amp;&amp; row &lt; rows &amp;&amp; column &gt;= <span class="hljs-number">0</span> &amp;&amp; column &lt; columns
    }
    <span class="hljs-keyword">subscript</span>(row: <span class="hljs-type">Int</span>, column: <span class="hljs-type">Int</span>) -&gt; <span class="hljs-type">Double</span> {
        <span class="hljs-keyword">get</span> {
            <span class="hljs-built_in">assert</span>(indexIsValid(row: row, column: column), <span class="hljs-string">&quot;Index out of range&quot;</span>)
            <span class="hljs-keyword">return</span> grid[(row * columns) + column]
        }
        <span class="hljs-keyword">set</span> {
            <span class="hljs-built_in">assert</span>(indexIsValid(row: row, column: column), <span class="hljs-string">&quot;Index out of range&quot;</span>)
            grid[(row * columns) + column] = newValue
        }
    }
}
</code></pre>
<p><code>Matrix</code> &#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E2A;&#x63A5;&#x53D7;&#x4E24;&#x4E2A;&#x5165;&#x53C2;&#x7684;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#xFF0C;&#x5165;&#x53C2;&#x5206;&#x522B;&#x662F; <code>rows</code> &#x548C; <code>columns</code>&#xFF0C;&#x521B;&#x5EFA;&#x4E86;&#x4E00;&#x4E2A;&#x8DB3;&#x591F;&#x5BB9;&#x7EB3; <code>rows * columns</code> &#x4E2A; <code>Double</code> &#x7C7B;&#x578B;&#x7684;&#x503C;&#x7684;&#x6570;&#x7EC4;&#x3002;&#x901A;&#x8FC7;&#x4F20;&#x5165;&#x6570;&#x7EC4;&#x957F;&#x5EA6;&#x548C;&#x521D;&#x59CB;&#x503C; <code>0.0</code> &#x5230;&#x6570;&#x7EC4;&#x7684;&#x6784;&#x9020;&#x5668;&#xFF0C;&#x5C06;&#x77E9;&#x9635;&#x4E2D;&#x6BCF;&#x4E2A;&#x4F4D;&#x7F6E;&#x7684;&#x503C;&#x521D;&#x59CB;&#x5316;&#x4E3A; <code>0.0</code>&#x3002;&#x5173;&#x4E8E;&#x6570;&#x7EC4;&#x7684;&#x8FD9;&#x79CD;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#x8BF7;&#x53C2;&#x8003; <a href="04_Collection_Types.html#creating_an_array_with_a_default_value">&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x5E26;&#x6709;&#x9ED8;&#x8BA4;&#x503C;&#x7684;&#x6570;&#x7EC4;</a>&#x3002;</p>
<p>&#x4F60;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x4F20;&#x5165;&#x5408;&#x9002;&#x7684; <code>row</code> &#x548C; <code>column</code> &#x7684;&#x6570;&#x91CF;&#x6765;&#x6784;&#x9020;&#x4E00;&#x4E2A;&#x65B0;&#x7684; <code>Matrix</code> &#x5B9E;&#x4F8B;&#xFF1A;</p>
<pre><code class="lang-swift"><span class="hljs-keyword">var</span> matrix = <span class="hljs-type">Matrix</span>(rows: <span class="hljs-number">2</span>, columns: <span class="hljs-number">2</span>)
</code></pre>
<p>&#x4E0A;&#x4F8B;&#x4E2D;&#x521B;&#x5EFA;&#x4E86;&#x4E00;&#x4E2A; <code>Matrix</code> &#x5B9E;&#x4F8B;&#x6765;&#x8868;&#x793A;&#x4E24;&#x884C;&#x4E24;&#x5217;&#x7684;&#x77E9;&#x9635;&#x3002;&#x8BE5; <code>Matrix</code> &#x5B9E;&#x4F8B;&#x7684; <code>grid</code> &#x6570;&#x7EC4;&#x6309;&#x7167;&#x4ECE;&#x5DE6;&#x4E0A;&#x5230;&#x53F3;&#x4E0B;&#x7684;&#x9605;&#x8BFB;&#x987A;&#x5E8F;&#x5C06;&#x77E9;&#x9635;&#x6241;&#x5E73;&#x5316;&#x5B58;&#x50A8;&#xFF1A;</p>
<p><img src="https://docs.swift.org/swift-book/_images/subscriptMatrix01_2x.png" alt=""></p>
<p>&#x5C06; <code>row</code> &#x548C; <code>column</code> &#x7684;&#x503C;&#x4F20;&#x5165;&#x4E0B;&#x6807;&#x6765;&#x4E3A;&#x77E9;&#x9635;&#x8BBE;&#x503C;&#xFF0C;&#x4E0B;&#x6807;&#x7684;&#x5165;&#x53C2;&#x4F7F;&#x7528;&#x9017;&#x53F7;&#x5206;&#x9694;&#xFF1A;</p>
<pre><code class="lang-swift">matrix[<span class="hljs-number">0</span>, <span class="hljs-number">1</span>] = <span class="hljs-number">1.5</span>
matrix[<span class="hljs-number">1</span>, <span class="hljs-number">0</span>] = <span class="hljs-number">3.2</span>
</code></pre>
<p>&#x4E0A;&#x9762;&#x4E24;&#x6761;&#x8BED;&#x53E5;&#x5206;&#x522B;&#x8C03;&#x7528;&#x4E0B;&#x6807;&#x7684; setter &#x5C06;&#x77E9;&#x9635;&#x53F3;&#x4E0A;&#x89D2;&#x4F4D;&#x7F6E;&#xFF08;&#x5373; <code>row</code> &#x4E3A; <code>0</code>&#x3001;<code>column</code> &#x4E3A; <code>1</code> &#x7684;&#x4F4D;&#x7F6E;&#xFF09;&#x7684;&#x503C;&#x8BBE;&#x7F6E;&#x4E3A; <code>1.5</code>&#xFF0C;&#x5C06;&#x77E9;&#x9635;&#x5DE6;&#x4E0B;&#x89D2;&#x4F4D;&#x7F6E;&#xFF08;&#x5373; <code>row</code> &#x4E3A; <code>1</code>&#x3001;<code>column</code> &#x4E3A; <code>0</code> &#x7684;&#x4F4D;&#x7F6E;&#xFF09;&#x7684;&#x503C;&#x8BBE;&#x7F6E;&#x4E3A; <code>3.2</code>&#xFF1A;</p>
<p><img src="https://docs.swift.org/swift-book/_images/subscriptMatrix02_2x.png" alt=""></p>
<p><code>Matrix</code> &#x4E0B;&#x6807;&#x7684; getter &#x548C; setter &#x4E2D;&#x90FD;&#x542B;&#x6709;&#x65AD;&#x8A00;&#xFF0C;&#x7528;&#x6765;&#x68C0;&#x67E5;&#x4E0B;&#x6807;&#x5165;&#x53C2; <code>row</code> &#x548C; <code>column</code> &#x7684;&#x503C;&#x662F;&#x5426;&#x6709;&#x6548;&#x3002;&#x4E3A;&#x4E86;&#x65B9;&#x4FBF;&#x8FDB;&#x884C;&#x65AD;&#x8A00;&#xFF0C;<code>Matrix</code> &#x5305;&#x542B;&#x4E86;&#x4E00;&#x4E2A;&#x540D;&#x4E3A; <code>indexIsValid(row:column:)</code> &#x7684;&#x4FBF;&#x5229;&#x65B9;&#x6CD5;&#xFF0C;&#x7528;&#x6765;&#x68C0;&#x67E5;&#x5165;&#x53C2; <code>row</code> &#x548C; <code>column</code> &#x7684;&#x503C;&#x662F;&#x5426;&#x5728;&#x77E9;&#x9635;&#x8303;&#x56F4;&#x5185;&#xFF1A;</p>
<pre><code class="lang-swift"><span class="hljs-function"><span class="hljs-keyword">func</span> <span class="hljs-title">indexIsValid</span><span class="hljs-params">(row: Int, column: Int)</span></span> -&gt; <span class="hljs-type">Bool</span> {
    <span class="hljs-keyword">return</span> row &gt;= <span class="hljs-number">0</span> &amp;&amp; row &lt; rows &amp;&amp; column &gt;= <span class="hljs-number">0</span> &amp;&amp; column &lt; columns
}
</code></pre>
<p>&#x65AD;&#x8A00;&#x5728;&#x4E0B;&#x6807;&#x8D8A;&#x754C;&#x65F6;&#x89E6;&#x53D1;&#xFF1A;</p>
<pre><code class="lang-swift"><span class="hljs-keyword">let</span> someValue = matrix[<span class="hljs-number">2</span>, <span class="hljs-number">2</span>]
<span class="hljs-comment">// &#x65AD;&#x8A00;&#x5C06;&#x4F1A;&#x89E6;&#x53D1;&#xFF0C;&#x56E0;&#x4E3A; [2, 2] &#x5DF2;&#x7ECF;&#x8D85;&#x8FC7;&#x4E86; matrix &#x7684;&#x8303;&#x56F4;</span>
</code></pre>
<h2 id="type-subscripts">&#x7C7B;&#x578B;&#x4E0B;&#x6807;</h2>
<p>&#x6B63;&#x5982;&#x4E0A;&#x8282;&#x6240;&#x8FF0;&#xFF0C;&#x5B9E;&#x4F8B;&#x4E0B;&#x6807;&#x662F;&#x5728;&#x7279;&#x5B9A;&#x7C7B;&#x578B;&#x7684;&#x4E00;&#x4E2A;&#x5B9E;&#x4F8B;&#x4E0A;&#x8C03;&#x7528;&#x7684;&#x4E0B;&#x6807;&#x3002;&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x5B9A;&#x4E49;&#x4E00;&#x79CD;&#x5728;&#x8FD9;&#x4E2A;&#x7C7B;&#x578B;&#x672C;&#x8EAB;&#x4E0A;&#x8C03;&#x7528;&#x7684;&#x4E0B;&#x6807;&#x3002;&#x8FD9;&#x79CD;&#x4E0B;&#x6807;&#x7684;&#x7C7B;&#x578B;&#x88AB;&#x79F0;&#x4F5C;&#x7C7B;&#x578B;&#x4E0B;&#x6807;&#x3002;&#x4F60;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;&#x5728; <code>subscript</code> &#x5173;&#x952E;&#x5B57;&#x4E4B;&#x524D;&#x5199;&#x4E0B; <code>static</code> &#x5173;&#x952E;&#x5B57;&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x8868;&#x793A;&#x4E00;&#x4E2A;&#x7C7B;&#x578B;&#x4E0B;&#x6807;&#x3002;&#x7C7B;&#x53EF;&#x4EE5;&#x4F7F;&#x7528; <code>class</code> &#x5173;&#x952E;&#x5B57;&#x6765;&#x5141;&#x8BB8;&#x5B50;&#x7C7B;&#x91CD;&#x5199;&#x7236;&#x7C7B;&#x4E2D;&#x5BF9;&#x90A3;&#x4E2A;&#x4E0B;&#x6807;&#x7684;&#x5B9E;&#x73B0;&#x3002;&#x4E0B;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x5C55;&#x793A;&#x4E86;&#x5982;&#x4F55;&#x5B9A;&#x4E49;&#x548C;&#x8C03;&#x7528;&#x4E00;&#x4E2A;&#x7C7B;&#x578B;&#x4E0B;&#x6807;&#xFF1A;</p>
<pre><code>enum Planet: Int {
    case mercury = 1, venus, earth, mars, jupiter, saturn, uranus, neptune
    static subscript(n: Int) -&gt; Planet {
        return Planet(rawValue: n)!
    }
}
let mars = Planet[4]
print(mars)
</code></pre>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="11_Methods.html" class="navigation navigation-prev " aria-label="Previous page: 方法">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="13_Inheritance.html" class="navigation navigation-next " aria-label="Next page: 继承">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"下标","level":"1.3.12","depth":2,"next":{"title":"继承","level":"1.3.13","depth":2,"path":"chapter2/13_Inheritance.md","ref":"chapter2/13_Inheritance.md","articles":[]},"previous":{"title":"方法","level":"1.3.11","depth":2,"path":"chapter2/11_Methods.md","ref":"chapter2/11_Methods.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"chapter2/12_Subscripts.md","mtime":"2019-07-05T01:01:08.049Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-07-05T02:41:17.672Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src=""></script>
    <script src=""></script>
    
        
        <script src=""></script>
        
    
        
        <script src=""></script>
        
    
        
        <script src=""></script>
        
    
        
        <script src=""></script>
        
    
        
        <script src=""></script>
        
    
        
        <script src=""></script>
        
    

    </body>
</html>

